package com.hnust.root.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnust.root.common.base.response.BaseRestController;
import com.hnust.root.common.base.response.BaseResult;
import com.hnust.root.common.base.response.PageData;
import com.hnust.root.dao.entity.domain.OperationLog;
import com.hnust.root.service.inteface.OperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zhusir
 * @Date 2019/2/10
 * @Desc 日志接口
 */
@RestController
@RequestMapping("/log")
public class LogController extends BaseRestController {

    @Autowired
    private OperationLogService logService;

    @GetMapping("/all")
    public BaseResult<PageData> getAllLogPage(@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                                              @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) {
        IPage<OperationLog> logIPage = new Page<>(pageNum, pageSize);
        logIPage = logService.getAllLogPage(logIPage);

        return fillSuccessData(new PageData(logIPage));
    }
}
